/* * 程序清单：这是一个 I2C 设备使用例程
 * 例程导出了 i2c_TM1680_sample 命令到控制终端
 * 命令调用格式：i2c_TM1680_sample i2c1
 * 命令解释：命令第二个参数是要使用的I2C总线设备名称，为空则使用默认的I2C总线设备
 * 程序功能：通过 I2C 设备读取温湿度传感器 TM1680 的温湿度数据并打印
*/

#include <rtthread.h>
#include <rtdevice.h>
#include "iic.h"

#define TM1680_I2C_BUS_NAME          "i2c1"  /* 传感器连接的I2C总线设备名称 */
#define TM1680_ADDR_A                  0x72    /* A地址 */   //实际地址是0xE4 要左移1位
#define TM1680_ADDR_B                  0x73   /* B地址 */  //实际地址是0xE6 要左移1位


static struct rt_i2c_bus_device *i2c_bus = RT_NULL;     /* I2C总线设备句柄 */
static rt_bool_t initialized = RT_FALSE;                /* 传感器初始化状态 */

char name[RT_NAME_MAX];
     static rt_uint8_t   buf[50]={};
          struct rt_i2c_msg msgs;

void  TM1680_logo()
{


    init_TM1680(1,0);

                              buf[1]=0x00;//蓝
                              buf[2]=0x0f;//高位红低位蓝
                              buf[3]=0xff;
                              buf[4]=0xf0;
                              buf[5]=0x00;
                              buf[6]=0x00;//第一排

                                           buf[7]=0x00;
                                            buf[8]=0x01;
                                            buf[9]=0x00;
                                            buf[10]=0x80;
                                            buf[11]=0x00;
                                             buf[12]=0x00;
                              buf[13]=0x00;//蓝色
                                 buf[14]=0x01;
                                 buf[15]=0x18;//红色
                                 buf[16]=0x80;
                                  buf[17]=0x00;//绿色
                                  buf[18]=0x00;
                                                  buf[19]=0x00;
                                                     buf[20]=0x01;
                                                     buf[21]=0xc3;
                                                     buf[22]=0x80;
                                                      buf[23]=0x00;
                                                      buf[24]=0x00;

                                 buf[25]=0x00;
                                 buf[26]=0x01;
                                 buf[27]=0x24;
                                 buf[28]=0x80;
                                  buf[29]=0x00;
                                  buf[30]=0x00;

                                                      buf[31]=0x00;
                                                     buf[32]=0x01;
                                                     buf[33]=0x18;
                                                     buf[34]=0x80;
                                                      buf[35]=0x00;
                                                      buf[36]=0x00;

                                  buf[37]=0x00;
                                   buf[38]=0x01;
                                   buf[39]=0x5a;
                                   buf[40]=0x80;
                                    buf[41]=0x00;
                                    buf[42]=0x00;

                                                        buf[43]=0x00;
                                                        buf[44]=0x01;
                                                        buf[45]=0x18;
                                                        buf[46]=0x80;
                                                         buf[47]=0x00;
                                                         buf[48]=0x00;

                            // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                             msgs.flags = RT_I2C_WR;
                             msgs.buf = buf;
                             msgs.len = 49;
                             rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;




                             init_TM1680(0,1);



                                         buf[1]=0x00;//蓝
                                         buf[2]=0x01;//高位红低位蓝
                                          buf[3]=0x18;
                                          buf[4]=0x80;
                                         buf[5]=0x00;
                                            buf[6]=0x00;//第一排

                                                      buf[7]=0x00;
                                                       buf[8]=0x01;
                                                       buf[9]=0x18;
                                                       buf[10]=0x80;
                                                       buf[11]=0x00;
                                                        buf[12]=0x00;
                                         buf[13]=0x00;//蓝色
                                            buf[14]=0x01;
                                            buf[15]=0x5a;//红色
                                            buf[16]=0x80;
                                             buf[17]=0x00;//绿色
                                             buf[18]=0x00;
                                                             buf[19]=0x00;
                                                                buf[20]=0x01;
                                                                buf[21]=0x99;
                                                                buf[22]=0x80;
                                                                 buf[23]=0x00;
                                                                 buf[24]=0x00;

                                            buf[25]=0x00;
                                            buf[26]=0x01;
                                            buf[27]=0x24;
                                            buf[28]=0x80;
                                             buf[29]=0x00;
                                             buf[30]=0x00;

                                                                 buf[31]=0x00;
                                                                buf[32]=0x01;
                                                                buf[33]=0xc3;
                                                                buf[34]=0x80;
                                                                 buf[35]=0x00;
                                                                 buf[36]=0x00;

                                             buf[37]=0x00;
                                              buf[38]=0x01;
                                              buf[39]=0x00;
                                              buf[40]=0x80;
                                               buf[41]=0x00;
                                               buf[42]=0x00;

                                                                   buf[43]=0x00;
                                                                   buf[44]=0x0f;
                                                                   buf[45]=0xff;
                                                                   buf[46]=0xf0;
                                                                    buf[47]=0x00;
                                                                    buf[48]=0x00;

                                       // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                        msgs.flags = RT_I2C_WR;
                                        msgs.buf = buf;
                                        msgs.len = 49;
                                        rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;


                                        rt_thread_mdelay(300);




    init_TM1680(1,0);

                           buf[1]=0x00;//蓝
                           buf[2]=0x0f;//高位红低位蓝
                           buf[3]=0xff;
                           buf[4]=0xf0;
                           buf[5]=0x00;
                           buf[6]=0x00;//第一排

                                        buf[7]=0x00;
                                         buf[8]=0x01;
                                         buf[9]=0x00;
                                         buf[10]=0x80;
                                         buf[11]=0x00;
                                          buf[12]=0x00;
                           buf[13]=0x00;//蓝色
                              buf[14]=0x01;
                              buf[15]=0x00;//红色
                              buf[16]=0x80;
                               buf[17]=0x18;//绿色
                               buf[18]=0x00;
                                               buf[19]=0x00;
                                                  buf[20]=0x01;
                                                  buf[21]=0x00;
                                                  buf[22]=0x80;
                                                   buf[23]=0xc3;
                                                   buf[24]=0x00;

                              buf[25]=0x00;
                              buf[26]=0x01;
                              buf[27]=0x00;
                              buf[28]=0x80;
                               buf[29]=0x24;
                               buf[30]=0x00;

                                                   buf[31]=0x00;
                                                  buf[32]=0x01;
                                                  buf[33]=0x00;
                                                  buf[34]=0x80;
                                                   buf[35]=0x18;
                                                   buf[36]=0x00;

                               buf[37]=0x00;
                                buf[38]=0x01;
                                buf[39]=0x00;
                                buf[40]=0x80;
                                 buf[41]=0x5a;
                                 buf[42]=0x00;

                                                     buf[43]=0x00;
                                                     buf[44]=0x01;
                                                     buf[45]=0x00;
                                                     buf[46]=0x80;
                                                      buf[47]=0x18;
                                                      buf[48]=0x00;

                         // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                          msgs.flags = RT_I2C_WR;
                          msgs.buf = buf;
                          msgs.len = 49;
                          rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;




                          init_TM1680(0,1);



                                      buf[1]=0x00;//蓝
                                      buf[2]=0x01;//高位红低位蓝
                                       buf[3]=0x00;
                                       buf[4]=0x80;
                                      buf[5]=0x18;
                                         buf[6]=0x00;//第一排

                                                   buf[7]=0x00;
                                                    buf[8]=0x01;
                                                    buf[9]=0x00;
                                                    buf[10]=0x80;
                                                    buf[11]=0x18;
                                                     buf[12]=0x00;
                                      buf[13]=0x00;//蓝色
                                         buf[14]=0x01;
                                         buf[15]=0x00;//红色
                                         buf[16]=0x80;
                                          buf[17]=0x5a;//绿色
                                          buf[18]=0x00;
                                                          buf[19]=0x00;
                                                             buf[20]=0x01;
                                                             buf[21]=0x00;
                                                             buf[22]=0x80;
                                                              buf[23]=0x99;
                                                              buf[24]=0x00;

                                         buf[25]=0x00;
                                         buf[26]=0x01;
                                         buf[27]=0x00;
                                         buf[28]=0x80;
                                          buf[29]=0x24;
                                          buf[30]=0x00;

                                                              buf[31]=0x00;
                                                             buf[32]=0x01;
                                                             buf[33]=0x00;
                                                             buf[34]=0x80;
                                                              buf[35]=0xc3;
                                                              buf[36]=0x00;

                                          buf[37]=0x00;
                                           buf[38]=0x01;
                                           buf[39]=0x00;
                                           buf[40]=0x80;
                                            buf[41]=0x00;
                                            buf[42]=0x00;

                                                                buf[43]=0x00;
                                                                buf[44]=0x0f;
                                                                buf[45]=0xff;
                                                                buf[46]=0xf0;
                                                                 buf[47]=0x00;
                                                                 buf[48]=0x00;

                                    // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                     msgs.flags = RT_I2C_WR;
                                     msgs.buf = buf;
                                     msgs.len = 49;
                                     rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                                     rt_thread_mdelay(400);


                                     init_TM1680(1,0);

                                                              buf[1]=0x00;//蓝
                                                              buf[2]=0x0f;//高位红低位蓝
                                                              buf[3]=0xff;
                                                              buf[4]=0xf0;
                                                              buf[5]=0x00;
                                                              buf[6]=0x00;//第一排

                                                                           buf[7]=0x00;
                                                                            buf[8]=0x01;
                                                                            buf[9]=0x00;
                                                                            buf[10]=0x80;
                                                                            buf[11]=0x00;
                                                                             buf[12]=0x00;
                                                              buf[13]=0x18;//蓝色
                                                                 buf[14]=0x01;
                                                                 buf[15]=0x00;//红色
                                                                 buf[16]=0x80;
                                                                  buf[17]=0x00;//绿色
                                                                  buf[18]=0x00;
                                                                                  buf[19]=0xc3;
                                                                                     buf[20]=0x01;
                                                                                     buf[21]=0x00;
                                                                                     buf[22]=0x80;
                                                                                      buf[23]=0x00;
                                                                                      buf[24]=0x00;

                                                                 buf[25]=0x24;
                                                                 buf[26]=0x01;
                                                                 buf[27]=0x00;
                                                                 buf[28]=0x80;
                                                                  buf[29]=0x00;
                                                                  buf[30]=0x00;

                                                                                      buf[31]=0x18;
                                                                                     buf[32]=0x01;
                                                                                     buf[33]=0x00;
                                                                                     buf[34]=0x80;
                                                                                      buf[35]=0x00;
                                                                                      buf[36]=0x00;

                                                                  buf[37]=0x5a;
                                                                   buf[38]=0x01;
                                                                   buf[39]=0x00;
                                                                   buf[40]=0x80;
                                                                    buf[41]=0x00;
                                                                    buf[42]=0x00;

                                                                                        buf[43]=0x18;
                                                                                        buf[44]=0x01;
                                                                                        buf[45]=0x00;
                                                                                        buf[46]=0x80;
                                                                                         buf[47]=0x00;
                                                                                         buf[48]=0x00;

                                                            // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                                             msgs.flags = RT_I2C_WR;
                                                             msgs.buf = buf;
                                                             msgs.len = 49;
                                                             rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;




                                                             init_TM1680(0,1);



                                                                         buf[1]=0x18;//蓝
                                                                         buf[2]=0x01;//高位红低位蓝
                                                                          buf[3]=0x00;
                                                                          buf[4]=0x80;
                                                                         buf[5]=0x00;
                                                                            buf[6]=0x00;//第一排

                                                                                      buf[7]=0x18;
                                                                                       buf[8]=0x01;
                                                                                       buf[9]=0x00;
                                                                                       buf[10]=0x80;
                                                                                       buf[11]=0x00;
                                                                                        buf[12]=0x00;
                                                                         buf[13]=0x5a;//蓝色
                                                                            buf[14]=0x01;
                                                                            buf[15]=0x00;//红色
                                                                            buf[16]=0x80;
                                                                             buf[17]=0x00;//绿色
                                                                             buf[18]=0x00;
                                                                                             buf[19]=0x99;
                                                                                                buf[20]=0x01;
                                                                                                buf[21]=0x00;
                                                                                                buf[22]=0x80;
                                                                                                 buf[23]=0x00;
                                                                                                 buf[24]=0x00;

                                                                            buf[25]=0x24;
                                                                            buf[26]=0x01;
                                                                            buf[27]=0x00;
                                                                            buf[28]=0x80;
                                                                             buf[29]=0x00;
                                                                             buf[30]=0x00;

                                                                                                 buf[31]=0xc3;
                                                                                                buf[32]=0x01;
                                                                                                buf[33]=0x00;
                                                                                                buf[34]=0x80;
                                                                                                 buf[35]=0x00;
                                                                                                 buf[36]=0x00;

                                                                             buf[37]=0x00;
                                                                              buf[38]=0x01;
                                                                              buf[39]=0x00;
                                                                              buf[40]=0x80;
                                                                               buf[41]=0x00;
                                                                               buf[42]=0x00;

                                                                                                   buf[43]=0x00;
                                                                                                   buf[44]=0x0f;
                                                                                                   buf[45]=0xff;
                                                                                                   buf[46]=0xf0;
                                                                                                    buf[47]=0x00;
                                                                                                    buf[48]=0x00;

                                                                       // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                                                        msgs.flags = RT_I2C_WR;
                                                                        msgs.buf = buf;
                                                                        msgs.len = 49;
                                                                        rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;





}
  void TM1680_one()
{


    init_TM1680(1,0);

                           buf[1]=0x00;//蓝
                           buf[2]=0x00;//高位红低位蓝
                           buf[3]=0xc3;
                           buf[4]=0x00;
                           buf[5]=0x00;
                           buf[6]=0x00;//第一排

                                        buf[7]=0x80;
                                         buf[8]=0x00;
                                         buf[9]=0x46;
                                         buf[10]=0x00;
                                         buf[11]=0x01;
                                          buf[12]=0x00;
                           buf[13]=0x80;//蓝色
                              buf[14]=0x00;
                              buf[15]=0x4e;//红色
                              buf[16]=0x00;
                               buf[17]=0x01;//绿色
                               buf[18]=0x00;
                                               buf[19]=0x80;
                                                  buf[20]=0x00;
                                                  buf[21]=0x42;
                                                  buf[22]=0x00;
                                                   buf[23]=0x01;
                                                   buf[24]=0x00;

                              buf[25]=0x80;
                              buf[26]=0x00;
                              buf[27]=0x42;
                              buf[28]=0x00;
                               buf[29]=0x01;
                               buf[30]=0x00;

                                                   buf[31]=0x80;
                                                  buf[32]=0x00;
                                                  buf[33]=0x42;
                                                  buf[34]=0x00;
                                                   buf[35]=0x01;
                                                   buf[36]=0x00;

                               buf[37]=0x80;
                                buf[38]=0x00;
                                buf[39]=0x42;
                                buf[40]=0x00;
                                 buf[41]=0x01;
                                 buf[42]=0x00;

                                                     buf[43]=0x80;
                                                     buf[44]=0x00;
                                                     buf[45]=0x42;
                                                     buf[46]=0x00;
                                                      buf[47]=0x01;
                                                      buf[48]=0x00;

                         // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                          msgs.flags = RT_I2C_WR;
                          msgs.buf = buf;
                          msgs.len = 49;
                          rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;




                          init_TM1680(0,1);



                                      buf[1]=0x80;//蓝
                                      buf[2]=0x00;//高位红低位蓝
                                       buf[3]=0x42;
                                       buf[4]=0x00;
                                      buf[5]=0x01;
                                         buf[6]=0x00;//第一排

                                                   buf[7]=0x80;
                                                    buf[8]=0x00;
                                                    buf[9]=0x42;
                                                    buf[10]=0x00;
                                                    buf[11]=0x01;
                                                     buf[12]=0x00;
                                      buf[13]=0x80;//蓝色
                                         buf[14]=0x00;
                                         buf[15]=0x42;//红色
                                         buf[16]=0x00;
                                          buf[17]=0x01;//绿色
                                          buf[18]=0x00;
                                                          buf[19]=0x80;
                                                             buf[20]=0x00;
                                                             buf[21]=0x42;
                                                             buf[22]=0x00;
                                                              buf[23]=0x01;
                                                              buf[24]=0x00;

                                         buf[25]=0x80;
                                         buf[26]=0x00;
                                         buf[27]=0x42;
                                         buf[28]=0x00;
                                          buf[29]=0x01;
                                          buf[30]=0x00;

                                                              buf[31]=0x80;
                                                             buf[32]=0x00;
                                                             buf[33]=0x7e;
                                                             buf[34]=0x00;
                                                              buf[35]=0x01;
                                                              buf[36]=0x00;

                                          buf[37]=0x80;
                                           buf[38]=0x00;
                                           buf[39]=0x7e;
                                           buf[40]=0x00;
                                            buf[41]=0x01;
                                            buf[42]=0x00;

                                                                buf[43]=0x00;
                                                                buf[44]=0x00;
                                                                buf[45]=0xff;
                                                                buf[46]=0x00;
                                                                 buf[47]=0x00;
                                                                 buf[48]=0x00;

                                    // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                     msgs.flags = RT_I2C_WR;
                                     msgs.buf = buf;
                                     msgs.len = 49;
                                     rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;


}
 void TM1680_two()
{
     init_TM1680(1,0);

                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0xc3;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x00;
                                           buf[9]=0x24;
                                           buf[10]=0x00;
                                           buf[11]=0xc3;
                                            buf[12]=0x00;
                             buf[13]=0x00;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xdb;//红色
                                buf[16]=0x00;
                                 buf[17]=0x24;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x00;
                                                    buf[20]=0x00;
                                                    buf[21]=0x5A;
                                                    buf[22]=0x00;
                                                     buf[23]=0x24;
                                                     buf[24]=0x00;

                                buf[25]=0x00;
                                buf[26]=0x00;
                                buf[27]=0x5E;
                                buf[28]=0x00;
                                 buf[29]=0x20;
                                 buf[30]=0x00;

                                                     buf[31]=0x00;
                                                    buf[32]=0x00;
                                                    buf[33]=0x50;
                                                    buf[34]=0x00;
                                                     buf[35]=0x20;
                                                     buf[36]=0x00;

                                 buf[37]=0x00;
                                  buf[38]=0x00;
                                  buf[39]=0x50;
                                  buf[40]=0x00;
                                   buf[41]=0x20;
                                   buf[42]=0x00;

                                                       buf[43]=0x00;
                                                       buf[44]=0x00;
                                                       buf[45]=0xa0;
                                                       buf[46]=0x00;
                                                        buf[47]=0x40;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);



                                        buf[1]=0x00;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0x41;
                                         buf[4]=0x00;
                                        buf[5]=0x80;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x00;
                                                      buf[9]=0x82;
                                                      buf[10]=0x00;
                                                      buf[11]=0x01;
                                                       buf[12]=0x00;
                                        buf[13]=0x00;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0x05;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x02;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x00;
                                                               buf[20]=0x00;
                                                               buf[21]=0x0a;
                                                               buf[22]=0x00;
                                                                buf[23]=0x04;
                                                                buf[24]=0x00;

                                           buf[25]=0x00;
                                           buf[26]=0x00;
                                           buf[27]=0x0a;
                                           buf[28]=0x00;
                                            buf[29]=0x04;
                                            buf[30]=0x00;

                                                                buf[31]=0x00;
                                                               buf[32]=0x00;
                                                               buf[33]=0xfb;
                                                               buf[34]=0x00;
                                                                buf[35]=0x04;
                                                                buf[36]=0x00;

                                            buf[37]=0x00;
                                             buf[38]=0x00;
                                             buf[39]=0x18;
                                             buf[40]=0x00;
                                              buf[41]=0xe7;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0xff;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

 void TM1680_three()
{
    init_TM1680(1,0);


                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0xc3;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0xc3;
                                           buf[8]=0x00;
                                           buf[9]=0x24;
                                           buf[10]=0x00;
                                           buf[11]=0x00;
                                            buf[12]=0x00;
                             buf[13]=0x24;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xdb;//红色
                                buf[16]=0x00;
                                 buf[17]=0x00;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x24;
                                                    buf[20]=0x00;
                                                    buf[21]=0x5A;
                                                    buf[22]=0x00;
                                                     buf[23]=0x00;
                                                     buf[24]=0x00;

                                buf[25]=0x20;
                                buf[26]=0x00;
                                buf[27]=0x5E;
                                buf[28]=0x00;
                                 buf[29]=0x00;
                                 buf[30]=0x00;

                                                     buf[31]=0x20;
                                                    buf[32]=0x00;
                                                    buf[33]=0x50;
                                                    buf[34]=0x00;
                                                     buf[35]=0x00;
                                                     buf[36]=0x00;

                                 buf[37]=0x20;
                                  buf[38]=0x00;
                                  buf[39]=0xd0;
                                  buf[40]=0x00;
                                   buf[41]=0x00;
                                   buf[42]=0x00;

                                                       buf[43]=0xc0;
                                                       buf[44]=0x00;
                                                       buf[45]=0x21;
                                                       buf[46]=0x00;
                                                        buf[47]=0x00;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);

                                        buf[1]=0xc0;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0x21;
                                         buf[4]=0x00;
                                        buf[5]=0x00;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x20;
                                                      buf[8]=0x00;
                                                      buf[9]=0xd0;
                                                      buf[10]=0x00;
                                                      buf[11]=0x00;
                                                       buf[12]=0x00;
                                        buf[13]=0x20;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0x50;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x00;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x20;
                                                               buf[20]=0x00;
                                                               buf[21]=0x5e;
                                                               buf[22]=0x00;
                                                                buf[23]=0x00;
                                                                buf[24]=0x00;

                                           buf[25]=0x24;
                                           buf[26]=0x00;
                                           buf[27]=0x5a;
                                           buf[28]=0x00;
                                            buf[29]=0x00;
                                            buf[30]=0x00;

                                                                buf[31]=0x24;
                                                               buf[32]=0x00;
                                                               buf[33]=0xdb;
                                                               buf[34]=0x00;
                                                                buf[35]=0x00;
                                                                buf[36]=0x00;

                                            buf[37]=0xc3;
                                             buf[38]=0x00;
                                             buf[39]=0x24;
                                             buf[40]=0x00;
                                              buf[41]=0x00;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0xc3;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}
 void TM1680_four()
{
     init_TM1680(1,0);


                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0xc0;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0xc0;
                                           buf[8]=0x00;
                                           buf[9]=0x21;
                                           buf[10]=0x00;
                                           buf[11]=0xc0;
                                            buf[12]=0x00;
                             buf[13]=0xc0;//蓝色
                                buf[14]=0x00;
                                buf[15]=0x21;//红色
                                buf[16]=0x00;
                                 buf[17]=0xc0;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x41;
                                                    buf[20]=0x00;
                                                    buf[21]=0xa2;
                                                    buf[22]=0x00;
                                                     buf[23]=0x41;
                                                     buf[24]=0x00;

                                buf[25]=0x41;
                                buf[26]=0x00;
                                buf[27]=0xa2;
                                buf[28]=0x00;
                                 buf[29]=0x41;
                                 buf[30]=0x00;

                                                     buf[31]=0x42;
                                                    buf[32]=0x00;
                                                    buf[33]=0xa5;
                                                    buf[34]=0x00;
                                                     buf[35]=0x42;
                                                     buf[36]=0x00;

                                 buf[37]=0x42;
                                  buf[38]=0x00;
                                  buf[39]=0xa5;
                                  buf[40]=0x00;
                                   buf[41]=0x42;
                                   buf[42]=0x00;

                                                       buf[43]=0x44;
                                                       buf[44]=0x00;
                                                       buf[45]=0xaa;
                                                       buf[46]=0x00;
                                                        buf[47]=0x44;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);



                                        buf[1]=0x44;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0xaa;
                                         buf[4]=0x00;
                                        buf[5]=0x44;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x44;
                                                      buf[8]=0x00;
                                                      buf[9]=0xaa;
                                                      buf[10]=0x00;
                                                      buf[11]=0x44;
                                                       buf[12]=0x00;
                                        buf[13]=0x44;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0xbb;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x44;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0xe7;
                                                               buf[20]=0x00;
                                                               buf[21]=0x18;
                                                               buf[22]=0x00;
                                                                buf[23]=0xe7;
                                                                buf[24]=0x00;

                                           buf[25]=0x40;
                                           buf[26]=0x00;
                                           buf[27]=0xbf;
                                           buf[28]=0x00;
                                            buf[29]=0x40;
                                            buf[30]=0x00;

                                                                buf[31]=0x40;
                                                               buf[32]=0x00;
                                                               buf[33]=0xa0;
                                                               buf[34]=0x00;
                                                                buf[35]=0x40;
                                                                buf[36]=0x00;

                                            buf[37]=0x40;
                                             buf[38]=0x00;
                                             buf[39]=0xa0;
                                             buf[40]=0x00;
                                              buf[41]=0x40;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0xe0;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_five()
{
      init_TM1680(1,0);


                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0xff;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x00;
                                           buf[9]=0x18;
                                           buf[10]=0x00;
                                           buf[11]=0xe7;
                                            buf[12]=0x00;
                             buf[13]=0x00;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xfb;//红色
                                buf[16]=0x00;
                                 buf[17]=0x04;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x00;
                                                    buf[20]=0x00;
                                                    buf[21]=0x0a;
                                                    buf[22]=0x00;
                                                     buf[23]=0x04;
                                                     buf[24]=0x00;

                                buf[25]=0x00;
                                buf[26]=0x00;
                                buf[27]=0x0a;
                                buf[28]=0x00;
                                 buf[29]=0x04;
                                 buf[30]=0x00;

                                                     buf[31]=0x00;
                                                    buf[32]=0x00;
                                                    buf[33]=0x0a;
                                                    buf[34]=0x00;
                                                     buf[35]=0x04;
                                                     buf[36]=0x00;

                                 buf[37]=0x00;
                                  buf[38]=0x00;
                                  buf[39]=0xcb;
                                  buf[40]=0x00;
                                   buf[41]=0x04;
                                   buf[42]=0x00;

                                                       buf[43]=0x00;
                                                       buf[44]=0x00;
                                                       buf[45]=0x28;
                                                       buf[46]=0x00;
                                                        buf[47]=0xc7;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;


                            init_TM1680(0,1);

                                        buf[1]=0x00;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0xd7;
                                         buf[4]=0x00;
                                        buf[5]=0x20;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x00;
                                                      buf[9]=0x50;
                                                      buf[10]=0x00;
                                                      buf[11]=0x20;
                                                       buf[12]=0x00;
                                        buf[13]=0x00;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0x50;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x20;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x00;
                                                               buf[20]=0x00;
                                                               buf[21]=0x5e;
                                                               buf[22]=0x00;
                                                                buf[23]=0x20;
                                                                buf[24]=0x00;

                                           buf[25]=0x00;
                                           buf[26]=0x00;
                                           buf[27]=0x5a;
                                           buf[28]=0x00;
                                            buf[29]=0x24;
                                            buf[30]=0x00;

                                                                buf[31]=0x00;
                                                               buf[32]=0x00;
                                                               buf[33]=0x5b;
                                                               buf[34]=0x00;
                                                                buf[35]=0x24;
                                                                buf[36]=0x00;

                                            buf[37]=0x00;
                                             buf[38]=0x00;
                                             buf[39]=0x24;
                                             buf[40]=0x00;
                                              buf[41]=0xc3;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0xc3;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_six()
{
      init_TM1680(1,0);


                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0xc1;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x00;
                                           buf[9]=0xe3;
                                           buf[10]=0x00;
                                           buf[11]=0xc1;
                                            buf[12]=0x00;
                             buf[13]=0x00;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xf7;//红色
                                buf[16]=0x00;
                                 buf[17]=0x22;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x00;
                                                    buf[20]=0x00;
                                                    buf[21]=0x3e;
                                                    buf[22]=0x00;
                                                     buf[23]=0x04;
                                                     buf[24]=0x00;

                                buf[25]=0x00;
                                buf[26]=0x00;
                                buf[27]=0x0e;
                                buf[28]=0x00;
                                 buf[29]=0x04;
                                 buf[30]=0x00;

                                                     buf[31]=0x00;
                                                    buf[32]=0x00;
                                                    buf[33]=0x0e;
                                                    buf[34]=0x00;
                                                     buf[35]=0x04;
                                                     buf[36]=0x00;

                                 buf[37]=0x00;
                                  buf[38]=0x00;
                                  buf[39]=0xcf;
                                  buf[40]=0x00;
                                   buf[41]=0x04;
                                   buf[42]=0x00;

                                                       buf[43]=0x00;
                                                       buf[44]=0x00;
                                                       buf[45]=0xef;
                                                       buf[46]=0x00;
                                                        buf[47]=0xc7;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;


                            init_TM1680(0,1);

                                        buf[1]=0x00;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0xff;
                                         buf[4]=0x00;
                                        buf[5]=0x24;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x00;
                                                      buf[9]=0x7e;
                                                      buf[10]=0x00;
                                                      buf[11]=0x24;
                                                       buf[12]=0x00;
                                        buf[13]=0x00;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0x7e;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x24;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x00;
                                                               buf[20]=0x00;
                                                               buf[21]=0x7e;
                                                               buf[22]=0x00;
                                                                buf[23]=0x24;
                                                                buf[24]=0x00;

                                           buf[25]=0x00;
                                           buf[26]=0x00;
                                           buf[27]=0x7e;
                                           buf[28]=0x00;
                                            buf[29]=0x24;
                                            buf[30]=0x00;

                                                                buf[31]=0x00;
                                                               buf[32]=0x00;
                                                               buf[33]=0xe7;
                                                               buf[34]=0x00;
                                                                buf[35]=0x42;
                                                                buf[36]=0x00;

                                            buf[37]=0x00;
                                             buf[38]=0x00;
                                             buf[39]=0xc3;
                                             buf[40]=0x00;
                                              buf[41]=0x81;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0x81;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_seven()
{
      init_TM1680(1,0);


                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0xff;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0xe7;
                                           buf[8]=0x00;
                                           buf[9]=0xff;
                                           buf[10]=0x00;
                                           buf[11]=0x00;
                                            buf[12]=0x00;
                             buf[13]=0x20;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xff;//红色
                                buf[16]=0x00;
                                 buf[17]=0x00;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x20;
                                                    buf[20]=0x00;
                                                    buf[21]=0x70;
                                                    buf[22]=0x00;
                                                     buf[23]=0x00;
                                                     buf[24]=0x00;

                                buf[25]=0x40;
                                buf[26]=0x00;
                                buf[27]=0xe0;
                                buf[28]=0x00;
                                 buf[29]=0x00;
                                 buf[30]=0x00;

                                                     buf[31]=0x40;
                                                    buf[32]=0x00;
                                                    buf[33]=0xe0;
                                                    buf[34]=0x00;
                                                     buf[35]=0x00;
                                                     buf[36]=0x00;

                                 buf[37]=0x40;
                                  buf[38]=0x00;
                                  buf[39]=0xe0;
                                  buf[40]=0x00;
                                   buf[41]=0x00;
                                   buf[42]=0x00;

                                                       buf[43]=0x80;
                                                       buf[44]=0x00;
                                                       buf[45]=0xc1;
                                                       buf[46]=0x00;
                                                        buf[47]=0x00;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);



                                        buf[1]=0x80;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0xc1;
                                         buf[4]=0x00;
                                        buf[5]=0x00;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x80;
                                                      buf[8]=0x00;
                                                      buf[9]=0xc1;
                                                      buf[10]=0x00;
                                                      buf[11]=0x00;
                                                       buf[12]=0x00;
                                        buf[13]=0x01;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0x83;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x00;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x01;
                                                               buf[20]=0x00;
                                                               buf[21]=0x83;
                                                               buf[22]=0x00;
                                                                buf[23]=0x00;
                                                                buf[24]=0x00;

                                           buf[25]=0x01;
                                           buf[26]=0x00;
                                           buf[27]=0x83;
                                           buf[28]=0x00;
                                            buf[29]=0x00;
                                            buf[30]=0x00;

                                                                buf[31]=0x02;
                                                               buf[32]=0x00;
                                                               buf[33]=0x07;
                                                               buf[34]=0x00;
                                                                buf[35]=0x00;
                                                                buf[36]=0x00;

                                            buf[37]=0x02;
                                             buf[38]=0x00;
                                             buf[39]=0x07;
                                             buf[40]=0x00;
                                              buf[41]=0x00;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0x07;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_eight()
{
      init_TM1680(1,0);

                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0x81;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x81;
                                           buf[8]=0x00;
                                           buf[9]=0xc3;
                                           buf[10]=0x00;
                                           buf[11]=0x81;
                                            buf[12]=0x00;
                             buf[13]=0x42;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xe7;//红色
                                buf[16]=0x00;
                                 buf[17]=0x42;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x24;
                                                    buf[20]=0x00;
                                                    buf[21]=0x7e;
                                                    buf[22]=0x00;
                                                     buf[23]=0x24;
                                                     buf[24]=0x00;

                                buf[25]=0x24;
                                buf[26]=0x00;
                                buf[27]=0x7e;
                                buf[28]=0x00;
                                 buf[29]=0x24;
                                 buf[30]=0x00;

                                                     buf[31]=0x24;
                                                    buf[32]=0x00;
                                                    buf[33]=0x7e;
                                                    buf[34]=0x00;
                                                     buf[35]=0x24;
                                                     buf[36]=0x00;

                                 buf[37]=0x42;
                                  buf[38]=0x00;
                                  buf[39]=0xe7;
                                  buf[40]=0x00;
                                   buf[41]=0x42;
                                   buf[42]=0x00;

                                                       buf[43]=0x81;
                                                       buf[44]=0x00;
                                                       buf[45]=0xc3;
                                                       buf[46]=0x00;
                                                        buf[47]=0x81;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);


                                        buf[1]=0x42;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0xe7;
                                         buf[4]=0x00;
                                        buf[5]=0x42;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x24;
                                                      buf[8]=0x00;
                                                      buf[9]=0x7e;
                                                      buf[10]=0x00;
                                                      buf[11]=0x24;
                                                       buf[12]=0x00;
                                        buf[13]=0x24;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0x7e;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x24;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x24;
                                                               buf[20]=0x00;
                                                               buf[21]=0x7e;
                                                               buf[22]=0x00;
                                                                buf[23]=0x24;
                                                                buf[24]=0x00;

                                           buf[25]=0x24;
                                           buf[26]=0x00;
                                           buf[27]=0x7e;
                                           buf[28]=0x00;
                                            buf[29]=0x24;
                                            buf[30]=0x00;

                                                                buf[31]=0x42;
                                                               buf[32]=0x00;
                                                               buf[33]=0xe7;
                                                               buf[34]=0x00;
                                                                buf[35]=0x42;
                                                                buf[36]=0x00;

                                            buf[37]=0x81;
                                             buf[38]=0x00;
                                             buf[39]=0xc3;
                                             buf[40]=0x00;
                                              buf[41]=0x81;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0x81;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

 void TM1680_nine()
{
     init_TM1680(1,0);

                             buf[1]=0x00;//蓝
                             buf[2]=0x00;//高位红低位蓝
                             buf[3]=0x81;
                             buf[4]=0x00;
                             buf[5]=0x00;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x00;
                                           buf[9]=0x42;
                                           buf[10]=0x00;
                                           buf[11]=0x81;
                                            buf[12]=0x00;
                             buf[13]=0x42;//蓝色
                                buf[14]=0x00;
                                buf[15]=0xa5;//红色
                                buf[16]=0x00;
                                 buf[17]=0x00;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x00;
                                                    buf[20]=0x00;
                                                    buf[21]=0x5A;
                                                    buf[22]=0x00;
                                                     buf[23]=0x24;
                                                     buf[24]=0x00;

                                buf[25]=0x24;
                                buf[26]=0x00;
                                buf[27]=0x5a;
                                buf[28]=0x00;
                                 buf[29]=0x00;
                                 buf[30]=0x00;

                                                     buf[31]=0x00;
                                                    buf[32]=0x00;
                                                    buf[33]=0x5a;
                                                    buf[34]=0x00;
                                                     buf[35]=0x24;
                                                     buf[36]=0x00;

                                 buf[37]=0x24;
                                  buf[38]=0x00;
                                  buf[39]=0x5a;
                                  buf[40]=0x00;
                                   buf[41]=0x00;
                                   buf[42]=0x00;

                                                       buf[43]=0x00;
                                                       buf[44]=0x00;
                                                       buf[45]=0x5a;
                                                       buf[46]=0x00;
                                                        buf[47]=0x24;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);


                                        buf[1]=0x62;//蓝
                                        buf[2]=0x00;//高位红低位蓝
                                         buf[3]=0x95;
                                         buf[4]=0x00;
                                        buf[5]=0x00;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x00;
                                                      buf[9]=0x52;
                                                      buf[10]=0x00;
                                                      buf[11]=0xa0;
                                                       buf[12]=0x00;
                                        buf[13]=0x20;//蓝色
                                           buf[14]=0x00;
                                           buf[15]=0xd1;//红色
                                           buf[16]=0x00;
                                            buf[17]=0x00;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x00;
                                                               buf[20]=0x00;
                                                               buf[21]=0x50;
                                                               buf[22]=0x00;
                                                                buf[23]=0x20;
                                                                buf[24]=0x00;

                                           buf[25]=0x20;
                                           buf[26]=0x00;
                                           buf[27]=0x5e;
                                           buf[28]=0x00;
                                            buf[29]=0x00;
                                            buf[30]=0x00;

                                                                buf[31]=0x00;
                                                               buf[32]=0x00;
                                                               buf[33]=0xab;
                                                               buf[34]=0x00;
                                                                buf[35]=0x44;
                                                                buf[36]=0x00;

                                            buf[37]=0x83;
                                             buf[38]=0x00;
                                             buf[39]=0x44;
                                             buf[40]=0x00;
                                              buf[41]=0x00;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x00;
                                                                  buf[45]=0x83;
                                                                  buf[46]=0x00;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_ten()
{
      init_TM1680(1,0);

                             buf[1]=0xa0;//蓝
                             buf[2]=0x08;//高位红低位蓝
                             buf[3]=0xb8;
                             buf[4]=0x30;
                             buf[5]=0xa0;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x04;
                                           buf[9]=0x28;
                                           buf[10]=0x48;
                                           buf[11]=0x10;
                                            buf[12]=0x30;
                             buf[13]=0x00;//蓝色
                                buf[14]=0x0a;
                                buf[15]=0x58;//红色
                                buf[16]=0x84;
                                 buf[17]=0x20;//绿色
                                 buf[18]=0x70;
                                                 buf[19]=0x00;
                                                    buf[20]=0x05;
                                                    buf[21]=0xa8;
                                                    buf[22]=0xe2;
                                                     buf[23]=0x40;
                                                     buf[24]=0x10;

                                buf[25]=0x00;
                                buf[26]=0x05;
                                buf[27]=0xa8;
                                buf[28]=0x22;
                                 buf[29]=0x40;
                                 buf[30]=0x10;

                                                     buf[31]=0x00;
                                                    buf[32]=0x05;
                                                    buf[33]=0xa8;
                                                    buf[34]=0x22;
                                                     buf[35]=0x40;
                                                     buf[36]=0x10;

                                 buf[37]=0x00;
                                  buf[38]=0x05;
                                  buf[39]=0xa8;
                                  buf[40]=0x22;
                                   buf[41]=0x40;
                                   buf[42]=0x10;

                                                       buf[43]=0x00;
                                                       buf[44]=0x05;
                                                       buf[45]=0xa8;
                                                       buf[46]=0x22;
                                                        buf[47]=0x40;
                                                        buf[48]=0x10;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;



                            init_TM1680(0,1);


                                        buf[1]=0x00;//蓝
                                        buf[2]=0x05;//高位红低位蓝
                                         buf[3]=0xa8;
                                         buf[4]=0x22;
                                        buf[5]=0x40;
                                           buf[6]=0x10;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x05;
                                                      buf[9]=0xa8;
                                                      buf[10]=0x22;
                                                      buf[11]=0x40;
                                                       buf[12]=0x10;
                                        buf[13]=0x00;//蓝色
                                           buf[14]=0x05;
                                           buf[15]=0xa8;//红色
                                           buf[16]=0x22;
                                            buf[17]=0x40;//绿色
                                            buf[18]=0x10;
                                                            buf[19]=0x00;
                                                               buf[20]=0x05;
                                                               buf[21]=0xa8;
                                                               buf[22]=0x22;
                                                                buf[23]=0x40;
                                                                buf[24]=0x10;

                                           buf[25]=0x00;
                                           buf[26]=0x05;
                                           buf[27]=0xa8;
                                           buf[28]=0x22;
                                            buf[29]=0x40;
                                            buf[30]=0x10;

                                                                buf[31]=0x00;
                                                               buf[32]=0x0a;
                                                               buf[33]=0x5e;
                                                               buf[34]=0xe4;
                                                                buf[35]=0x20;
                                                                buf[36]=0x10;

                                            buf[37]=0x00;
                                             buf[38]=0x04;
                                             buf[39]=0x22;
                                             buf[40]=0x88;
                                              buf[41]=0x1c;
                                              buf[42]=0x70;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x08;
                                                                  buf[45]=0x1e;
                                                                  buf[46]=0xf0;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_eleven()
{
      init_TM1680(1,0);

                             buf[1]=0x80;//蓝
                             buf[2]=0x08;//高位红低位蓝
                             buf[3]=0xb8;
                             buf[4]=0x30;
                             buf[5]=0x80;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x30;
                                           buf[8]=0x38;
                                           buf[9]=0x48;
                                           buf[10]=0x40;
                                           buf[11]=0x00;
                                            buf[12]=0x00;
                             buf[13]=0x70;//蓝色
                                buf[14]=0x78;
                                buf[15]=0x88;//红色
                                buf[16]=0x80;
                                 buf[17]=0x00;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x10;
                                                    buf[20]=0x18;
                                                    buf[21]=0xe8;
                                                    buf[22]=0xe0;
                                                     buf[23]=0x00;
                                                     buf[24]=0x00;

                                buf[25]=0x10;
                                buf[26]=0x18;
                                buf[27]=0x28;
                                buf[28]=0x20;
                                 buf[29]=0x00;
                                 buf[30]=0x00;

                                                     buf[31]=0x10;
                                                    buf[32]=0x18;
                                                    buf[33]=0x28;
                                                    buf[34]=0x20;
                                                     buf[35]=0x00;
                                                     buf[36]=0x00;

                                 buf[37]=0x10;
                                  buf[38]=0x18;
                                  buf[39]=0x28;
                                  buf[40]=0x20;
                                   buf[41]=0x00;
                                   buf[42]=0x00;

                                                       buf[43]=0x10;
                                                       buf[44]=0x18;
                                                       buf[45]=0x28;
                                                       buf[46]=0x20;
                                                        buf[47]=0x00;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);


                                        buf[1]=0x10;//蓝
                                        buf[2]=0x18;//高位红低位蓝
                                         buf[3]=0x28;
                                         buf[4]=0x20;
                                        buf[5]=0x00;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x10;
                                                      buf[8]=0x18;
                                                      buf[9]=0x28;
                                                      buf[10]=0x20;
                                                      buf[11]=0x00;
                                                       buf[12]=0x00;
                                        buf[13]=0x10;//蓝色
                                           buf[14]=0x18;
                                           buf[15]=0x28;//红色
                                           buf[16]=0x20;
                                            buf[17]=0x00;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x10;
                                                               buf[20]=0x18;
                                                               buf[21]=0x28;
                                                               buf[22]=0x20;
                                                                buf[23]=0x00;
                                                                buf[24]=0x00;

                                           buf[25]=0x10;
                                           buf[26]=0x18;
                                           buf[27]=0x28;
                                           buf[28]=0x20;
                                            buf[29]=0x00;
                                            buf[30]=0x00;

                                                                buf[31]=0x10;
                                                               buf[32]=0x1e;
                                                               buf[33]=0xee;
                                                               buf[34]=0xe0;
                                                                buf[35]=0x00;
                                                                buf[36]=0x0c;

                                            buf[37]=0x7c;
                                             buf[38]=0x72;
                                             buf[39]=0x82;
                                             buf[40]=0x80;
                                              buf[41]=0x00;
                                              buf[42]=0x00;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x0e;
                                                                  buf[45]=0xfe;
                                                                  buf[46]=0xf0;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_twelve()
{
      init_TM1680(1,0);

                             buf[1]=0x80;//蓝
                             buf[2]=0x0c;//高位红低位蓝
                             buf[3]=0xb8;
                             buf[4]=0x30;
                             buf[5]=0x80;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x32;
                                           buf[9]=0x48;
                                           buf[10]=0x4c;
                                           buf[11]=0x30;
                                            buf[12]=0x00;
                             buf[13]=0x00;//蓝色
                                buf[14]=0x7d;
                                buf[15]=0xb8;//红色
                                buf[16]=0x82;
                                 buf[17]=0x40;//绿色
                                 buf[18]=0x00;
                                                 buf[19]=0x00;
                                                    buf[20]=0x15;
                                                    buf[21]=0xa8;
                                                    buf[22]=0xe2;
                                                     buf[23]=0x40;
                                                     buf[24]=0x00;

                                buf[25]=0x00;
                                buf[26]=0x15;
                                buf[27]=0xe8;
                                buf[28]=0x22;
                                 buf[29]=0x00;
                                 buf[30]=0x00;

                                                     buf[31]=0x00;
                                                    buf[32]=0x15;
                                                    buf[33]=0x08;
                                                    buf[34]=0x22;
                                                     buf[35]=0x00;
                                                     buf[36]=0x00;

                                 buf[37]=0x00;
                                  buf[38]=0x15;
                                  buf[39]=0x08;
                                  buf[40]=0x22;
                                   buf[41]=0x00;
                                   buf[42]=0x00;

                                                       buf[43]=0x00;
                                                       buf[44]=0x15;
                                                       buf[45]=0x08;
                                                       buf[46]=0x22;
                                                        buf[47]=0x00;
                                                        buf[48]=0x00;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;



                            init_TM1680(0,1);


                                        buf[1]=0x00;//蓝
                                        buf[2]=0x1a;//高位红低位蓝
                                         buf[3]=0x08;
                                         buf[4]=0x24;
                                        buf[5]=0x00;
                                           buf[6]=0x00;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x14;
                                                      buf[9]=0x18;
                                                      buf[10]=0x28;
                                                      buf[11]=0x00;
                                                       buf[12]=0x00;
                                        buf[13]=0x00;//蓝色
                                           buf[14]=0x18;
                                           buf[15]=0x28;//红色
                                           buf[16]=0x20;
                                            buf[17]=0x10;//绿色
                                            buf[18]=0x00;
                                                            buf[19]=0x00;
                                                               buf[20]=0x10;
                                                               buf[21]=0x58;
                                                               buf[22]=0x20;
                                                                buf[23]=0x20;
                                                                buf[24]=0x00;

                                           buf[25]=0x00;
                                           buf[26]=0x10;
                                           buf[27]=0xa8;
                                           buf[28]=0x20;
                                            buf[29]=0x40;
                                            buf[30]=0x00;

                                                                buf[31]=0x00;
                                                               buf[32]=0x1f;
                                                               buf[33]=0xbe;
                                                               buf[34]=0xe0;
                                                                buf[35]=0x40;
                                                                buf[36]=0x00;

                                            buf[37]=0x0c;//1蓝
                                             buf[38]=0x71;//2前蓝，2后红
                                             buf[39]=0x82;//1红
                                             buf[40]=0x8e;//2前红，2后绿
                                              buf[41]=0x70;//1绿
                                              buf[42]=0x00;//2前绿，3后蓝

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x0f;
                                                                  buf[45]=0xfe;
                                                                  buf[46]=0xf0;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}

  void TM1680_thirteen()
{
      init_TM1680(1,0);

                             buf[1]=0x80;//蓝
                             buf[2]=0x08;//
                             buf[3]=0xb8;
                             buf[4]=0x30;
                             buf[5]=0x80;
                             buf[6]=0x00;//第一排

                                          buf[7]=0x00;
                                           buf[8]=0x04;
                                           buf[9]=0x48;
                                           buf[10]=0x48;
                                           buf[11]=0x30;
                                            buf[12]=0x30;
                             buf[13]=0x00;//蓝色
                                buf[14]=0x0a;
                                buf[15]=0xb8;//红色
                                buf[16]=0x84;
                                 buf[17]=0x40;//绿色
                                 buf[18]=0x70;
                                                 buf[19]=0x00;
                                                    buf[20]=0x05;
                                                    buf[21]=0xa8;
                                                    buf[22]=0xe2;
                                                     buf[23]=0x40;
                                                     buf[24]=0x10;

                                buf[25]=0x00;
                                buf[26]=0x05;
                                buf[27]=0xe8;
                                buf[28]=0x22;
                                 buf[29]=0x00;
                                 buf[30]=0x10;

                                                     buf[31]=0x00;
                                                    buf[32]=0x05;
                                                    buf[33]=0x08;
                                                    buf[34]=0x22;
                                                     buf[35]=0x00;
                                                     buf[36]=0x10;

                                 buf[37]=0x00;
                                  buf[38]=0x0a;
                                  buf[39]=0x08;
                                  buf[40]=0x24;
                                   buf[41]=0x00;
                                   buf[42]=0x10;

                                                       buf[43]=0x00;
                                                       buf[44]=0x04;
                                                       buf[45]=0x18;
                                                       buf[46]=0x28;
                                                        buf[47]=0x00;
                                                        buf[48]=0x10;

                           // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                            msgs.flags = RT_I2C_WR;
                            msgs.buf = buf;
                            msgs.len = 49;
                            rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

                            init_TM1680(0,1);


                                        buf[1]=0x00;//蓝
                                        buf[2]=0x02;//高位红低位蓝
                                         buf[3]=0x18;
                                         buf[4]=0x2c;
                                        buf[5]=0x00;
                                           buf[6]=0x10;//第一排

                                                     buf[7]=0x00;
                                                      buf[8]=0x09;
                                                      buf[9]=0x08;
                                                      buf[10]=0x26;
                                                      buf[11]=0x00;
                                                       buf[12]=0x10;
                                        buf[13]=0x00;//蓝色
                                           buf[14]=0x05;
                                           buf[15]=0x08;//红色
                                           buf[16]=0x22;
                                            buf[17]=0x00;//绿色
                                            buf[18]=0x10;
                                                            buf[19]=0x00;
                                                               buf[20]=0x05;
                                                               buf[21]=0xe8;
                                                               buf[22]=0x22;
                                                                buf[23]=0x00;
                                                                buf[24]=0x10;

                                           buf[25]=0x00;
                                           buf[26]=0x05;
                                           buf[27]=0xa8;
                                           buf[28]=0x22;
                                            buf[29]=0x40;
                                            buf[30]=0x10;

                                                                buf[31]=0x00;
                                                               buf[32]=0x0a;
                                                               buf[33]=0xbe;
                                                               buf[34]=0xe4;
                                                                buf[35]=0x40;
                                                                buf[36]=0x10;

                                            buf[37]=0x00;
                                             buf[38]=0x04;
                                             buf[39]=0x42;
                                             buf[40]=0x88;
                                              buf[41]=0x3c;
                                              buf[42]=0x70;

                                                                  buf[43]=0x00;
                                                                  buf[44]=0x08;
                                                                  buf[45]=0x3e;
                                                                  buf[46]=0xf0;
                                                                   buf[47]=0x00;
                                                                   buf[48]=0x00;

                                      // for(uint8_t i=25;i<49;i++)buf[i]=0x00;
                                       msgs.flags = RT_I2C_WR;
                                       msgs.buf = buf;
                                       msgs.len = 49;
                                       rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

}



void init_TM1680(uint8_t a,uint8_t b)
{
//    char name[RT_NAME_MAX];
//    static rt_uint8_t   buf[50]={};
//         struct rt_i2c_msg msgs;
       //  buf[0] = 0xe4;


        if(a)
        {
         buf[0] = 0x80;
         buf[1] = 0xa4;
          buf[2] =0x9A;
           buf[3] =0x90;
          buf[4] =0x81;
          buf[5] =0x83 ;
           buf[6] =0xb7;
           buf[7] =0x88;
        rt_strncpy(name, TM1680_I2C_BUS_NAME, RT_NAME_MAX);
         msgs.addr = TM1680_ADDR_A;
         msgs.flags = RT_I2C_WR;
         msgs.buf = buf;
         msgs.len = 8;
         /* 调用I2C设备接口传输数据 */
         rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;
          buf[0] =0x01;//开始地址
        }
        else   if(b)
        {

             buf[0] = 0x80;
                 buf[1] = 0xa4;
                 buf[2] =0x9A;
               //   buf[3] =0x90;
                  buf[4] =0x81;
                  buf[5] =0x83 ;
                   buf[6] =0xb7;
                   buf[7] =0x88;
                rt_strncpy(name, TM1680_I2C_BUS_NAME, RT_NAME_MAX);
                 msgs.addr = TM1680_ADDR_B;
                 msgs.flags = RT_I2C_WR;
                 msgs.buf = buf;
                 msgs.len = 7;
                 /* 调用I2C设备接口传输数据 */
                 rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;
              //   write_reg((struct rt_i2c_bus_device *)rt_device_find(name),0xE4,&msgs);
                        buf[0] =0x01;//开始地址
        }

                    buf[50]=0;
                     msgs.flags = RT_I2C_WR;
                      msgs.buf = buf;
                      msgs.len = 49;
                      rt_i2c_transfer((struct rt_i2c_bus_device *)rt_device_find(name), &msgs, 1) ;

      //   write_reg((struct rt_i2c_bus_device *)rt_device_find(name),0xE4,&msgs);
      //   rt_kprintf("name: %s\n",(struct rt_i2c_bus_device *)rt_device_find(name));
//        TM1680_one();
//        rt_thread_mdelay(500);
//         TM1680_two();
//         rt_thread_mdelay(500);
//         TM1680_three();
//         rt_thread_mdelay(500);
//          TM1680_four();
//          rt_thread_mdelay(500);
//          TM1680_five();
//          rt_thread_mdelay(500);
//          TM1680_six();
//          rt_thread_mdelay(500);
//                TM1680_seven();
//                rt_thread_mdelay(500);
//             TM1680_eight();
//              rt_thread_mdelay(500);
//                 TM1680_nine();
//         rt_thread_mdelay(500);
//            TM1680_ten();
//                  rt_thread_mdelay(500);
//                     TM1680_eleven();
//         rt_thread_mdelay(500);
//               TM1680_twelve();
//                  rt_thread_mdelay(500);
//                       TM1680_thirteen();

}
